import { useState } from "react";
import ChildOne from "./ChildOne";
import ChildTwo from "./ChildTwo";
import "./parent.css";

export default function Parent() {
  const [count, setCount] = useState(0);

  const receiveChild = (num) => {
    console.log("父组件接收到的数据", num);
    setCount(num);
  };

  return (
    <>
      <div className="container">
        <h1>我是父组件</h1>
        <p>ChildOne传递的num值：{count}</p>
      </div>
      <hr />
      <ChildOne onReceive={receiveChild} />
      <hr />
      <ChildTwo count={count} />
    </>
  );
}
